//
// Created by 董一龙 on 2022/10/13.
//

#ifndef FQUEUE_PLATFORM_INTERFACE_HPP
#define FQUEUE_PLATFORM_INTERFACE_HPP

#include <memory>

namespace fqueue {

    template <typename platform_impl_type>
    class platform_interface {
        using IMPL = platform_impl_type;
    public:
        platform_interface() = delete;
        ~platform_interface() = delete;

        static void *mmap(void *addr, size_t length, int prot, int flags, char const* const filename, off_t offset) {
            return IMPL::mmap(addr, length, prot, flags, filename, offset);
        }
        static int munmap(void *addr, size_t length) {
            return IMPL::munmap(addr, length);
        }

        static int create_file(char const*const filename, size_t file_size) {
            return IMPL::create_file(filename, file_size);
        }

        static size_t file_size(char const*const filename) {
            return IMPL::file_size(filename);
        }

        static bool exists(char const*const filename) {
            return IMPL::exists(filename) == 0;
        }
    };

} // fqueue




#endif //FQUEUE_PLATFORM_INTERFACE_HPP
